﻿using System;
using System.Collections.Generic;
using IllusionUtility.GetUtility;
using UnityEngine;

// Token: 0x02000568 RID: 1384
public abstract class ShapeInfoBase
{
	// Token: 0x06002168 RID: 8552 RVA: 0x0012EF00 File Offset: 0x0012D100
	public ShapeInfoBase()
	{
		this.InitEnd = false;
		this.dictCategory = new Dictionary<int, List<global::ShapeInfoBase.CategoryInfo>>();
		this.dictDstBoneInfo = new Dictionary<int, global::ShapeInfoBase.BoneInfo>();
		this.dictSrcBoneInfo = new Dictionary<int, global::ShapeInfoBase.BoneInfo>();
	}

	// Token: 0x1700038E RID: 910
	// (get) Token: 0x06002169 RID: 8553 RVA: 0x0012EF3C File Offset: 0x0012D13C
	// (set) Token: 0x0600216A RID: 8554 RVA: 0x0012EF44 File Offset: 0x0012D144
	public bool InitEnd { get; protected set; }

	// Token: 0x0600216B RID: 8555
	public abstract void InitShapeInfo(string assetBundleAnmKey, string assetBundleCategory, string anmKeyInfoName, string cateInfoName, Transform trfObj);

	// Token: 0x0600216C RID: 8556 RVA: 0x0012EF50 File Offset: 0x0012D150
	protected void InitShapeInfoBase(string assetBundleAnmKey, string assetBundleCategory, string anmKeyInfoName, string cateInfoName, Transform trfObj, Dictionary<string, int> dictEnumDst, Dictionary<string, int> dictEnumSrc)
	{
		this.anmKeyInfo.LoadInfo(assetBundleAnmKey, anmKeyInfoName);
		this.LoadCategoryInfoList(assetBundleCategory, cateInfoName, dictEnumSrc);
		this.GetDstBoneInfo(trfObj, dictEnumDst);
		this.GetSrcBoneInfo();
	}

	// Token: 0x0600216D RID: 8557 RVA: 0x0012EF7C File Offset: 0x0012D17C
	public void ReleaseShapeInfo()
	{
		this.InitEnd = false;
		this.dictCategory.Clear();
		this.dictDstBoneInfo.Clear();
		this.dictSrcBoneInfo.Clear();
	}

	// Token: 0x0600216E RID: 8558 RVA: 0x0012EFA8 File Offset: 0x0012D1A8
	private bool LoadCategoryInfoList(string assetBundleName, string assetName, Dictionary<string, int> dictEnumSrc)
	{
		if (!global::AssetBundleCheck.IsFile(assetBundleName, assetName))
		{
			string message = "読み込みエラー\r\nassetBundleName：" + assetBundleName + "\tassetName：" + assetName;
			global::Debug.LogError(message);
			return false;
		}
		global::AssetBundleLoadAssetOperation assetBundleLoadAssetOperation = global::AssetBundleManager.LoadAsset(assetBundleName, assetName, typeof(TextAsset), null);
		if (assetBundleLoadAssetOperation == null)
		{
			string message2 = "読み込みエラー\r\nassetName：" + assetName;
			global::Debug.LogError(message2);
			return false;
		}
		TextAsset asset = assetBundleLoadAssetOperation.GetAsset<TextAsset>();
		if (null == asset)
		{
			global::Debug.LogError("ありえない");
			return false;
		}
		string[,] array;
		global::YS_Assist.GetListString(asset.text, out array);
		int length = array.GetLength(0);
		int length2 = array.GetLength(1);
		this.dictCategory.Clear();
		if (length != 0 && length2 != 0)
		{
			for (int i = 0; i < length; i++)
			{
				global::ShapeInfoBase.CategoryInfo categoryInfo = new global::ShapeInfoBase.CategoryInfo();
				categoryInfo.Initialize();
				int key = int.Parse(array[i, 0]);
				categoryInfo.name = array[i, 1];
				int id = 0;
				if (!dictEnumSrc.TryGetValue(categoryInfo.name, out id))
				{
					string message3 = "SrcBone【" + categoryInfo.name + "】のIDが見つかりません";
					global::Debug.LogWarning(message3);
				}
				else
				{
					categoryInfo.id = id;
					categoryInfo.use[0][0] = ((!(array[i, 2] == "0")) ? true : false);
					categoryInfo.use[0][1] = ((!(array[i, 3] == "0")) ? true : false);
					categoryInfo.use[0][2] = ((!(array[i, 4] == "0")) ? true : false);
					if (categoryInfo.use[0][0] || categoryInfo.use[0][1] || categoryInfo.use[0][2])
					{
						categoryInfo.getflag[0] = true;
					}
					categoryInfo.use[1][0] = ((!(array[i, 5] == "0")) ? true : false);
					categoryInfo.use[1][1] = ((!(array[i, 6] == "0")) ? true : false);
					categoryInfo.use[1][2] = ((!(array[i, 7] == "0")) ? true : false);
					if (categoryInfo.use[1][0] || categoryInfo.use[1][1] || categoryInfo.use[1][2])
					{
						categoryInfo.getflag[1] = true;
					}
					categoryInfo.use[2][0] = ((!(array[i, 8] == "0")) ? true : false);
					categoryInfo.use[2][1] = ((!(array[i, 9] == "0")) ? true : false);
					categoryInfo.use[2][2] = ((!(array[i, 10] == "0")) ? true : false);
					if (categoryInfo.use[2][0] || categoryInfo.use[2][1] || categoryInfo.use[2][2])
					{
						categoryInfo.getflag[2] = true;
					}
					List<global::ShapeInfoBase.CategoryInfo> list = null;
					if (!this.dictCategory.TryGetValue(key, out list))
					{
						list = new List<global::ShapeInfoBase.CategoryInfo>();
						this.dictCategory[key] = list;
					}
					list.Add(categoryInfo);
				}
			}
		}
		global::AssetBundleManager.UnloadAssetBundle(assetBundleName, true, null);
		return true;
	}

	// Token: 0x0600216F RID: 8559 RVA: 0x0012F364 File Offset: 0x0012D564
	private bool GetDstBoneInfo(Transform trfBone, Dictionary<string, int> dictEnumDst)
	{
		this.dictDstBoneInfo.Clear();
		foreach (KeyValuePair<string, int> keyValuePair in dictEnumDst)
		{
			GameObject gameObject = trfBone.FindLoop(keyValuePair.Key);
			if (null != gameObject)
			{
				global::ShapeInfoBase.BoneInfo boneInfo = new global::ShapeInfoBase.BoneInfo();
				boneInfo.trfBone = gameObject.transform;
				this.dictDstBoneInfo[keyValuePair.Value] = boneInfo;
			}
		}
		return true;
	}

	// Token: 0x06002170 RID: 8560 RVA: 0x0012F400 File Offset: 0x0012D600
	private void GetSrcBoneInfo()
	{
		this.dictSrcBoneInfo.Clear();
		foreach (KeyValuePair<int, List<global::ShapeInfoBase.CategoryInfo>> keyValuePair in this.dictCategory)
		{
			int count = keyValuePair.Value.Count;
			for (int i = 0; i < count; i++)
			{
				global::ShapeInfoBase.BoneInfo value = null;
				if (!this.dictSrcBoneInfo.TryGetValue(keyValuePair.Value[i].id, out value))
				{
					value = new global::ShapeInfoBase.BoneInfo();
					this.dictSrcBoneInfo[keyValuePair.Value[i].id] = value;
				}
			}
		}
	}

	// Token: 0x06002171 RID: 8561 RVA: 0x0012F4CC File Offset: 0x0012D6CC
	public bool ChangeValue(int category, float value)
	{
		if (this.anmKeyInfo == null)
		{
			return false;
		}
		if (!this.dictCategory.ContainsKey(category))
		{
			return false;
		}
		int count = this.dictCategory[category].Count;
		string name = string.Empty;
		for (int i = 0; i < count; i++)
		{
			List<global::ShapeInfoBase.CategoryInfo> list = this.dictCategory[category];
			global::ShapeInfoBase.BoneInfo boneInfo = null;
			int id = list[i].id;
			name = list[i].name;
			if (this.dictSrcBoneInfo.TryGetValue(id, out boneInfo))
			{
				Vector3[] array = new Vector3[3];
				for (int j = 0; j < 3; j++)
				{
					array[j] = Vector3.zero;
				}
				bool[] array2 = new bool[3];
				for (int k = 0; k < 3; k++)
				{
					array2[k] = list[i].getflag[k];
				}
				this.anmKeyInfo.GetInfo(name, value, ref array, array2);
				if (list[i].use[0][0])
				{
					boneInfo.vctPos.x = array[0].x;
				}
				if (list[i].use[0][1])
				{
					boneInfo.vctPos.y = array[0].y;
				}
				if (list[i].use[0][2])
				{
					boneInfo.vctPos.z = array[0].z;
				}
				if (list[i].use[1][0])
				{
					boneInfo.vctRot.x = array[1].x;
				}
				if (list[i].use[1][1])
				{
					boneInfo.vctRot.y = array[1].y;
				}
				if (list[i].use[1][2])
				{
					boneInfo.vctRot.z = array[1].z;
				}
				if (list[i].use[2][0])
				{
					boneInfo.vctScl.x = array[2].x;
				}
				if (list[i].use[2][1])
				{
					boneInfo.vctScl.y = array[2].y;
				}
				if (list[i].use[2][2])
				{
					boneInfo.vctScl.z = array[2].z;
				}
			}
		}
		return true;
	}

	// Token: 0x06002172 RID: 8562
	public abstract void Update();

	// Token: 0x04002986 RID: 10630
	private Dictionary<int, List<global::ShapeInfoBase.CategoryInfo>> dictCategory;

	// Token: 0x04002987 RID: 10631
	protected Dictionary<int, global::ShapeInfoBase.BoneInfo> dictDstBoneInfo;

	// Token: 0x04002988 RID: 10632
	protected Dictionary<int, global::ShapeInfoBase.BoneInfo> dictSrcBoneInfo;

	// Token: 0x04002989 RID: 10633
	private global::AnimationKeyInfo anmKeyInfo = new global::AnimationKeyInfo();

	// Token: 0x02000569 RID: 1385
	public class CategoryInfo
	{
		// Token: 0x06002174 RID: 8564 RVA: 0x0012F7B0 File Offset: 0x0012D9B0
		public void Initialize()
		{
			for (int i = 0; i < 3; i++)
			{
				this.use[i] = new bool[3];
				this.getflag[i] = false;
			}
		}

		// Token: 0x0400298B RID: 10635
		public int id;

		// Token: 0x0400298C RID: 10636
		public string name = string.Empty;

		// Token: 0x0400298D RID: 10637
		public bool[][] use = new bool[3][];

		// Token: 0x0400298E RID: 10638
		public bool[] getflag = new bool[3];
	}

	// Token: 0x0200056A RID: 1386
	public class BoneInfo
	{
		// Token: 0x0400298F RID: 10639
		public Transform trfBone;

		// Token: 0x04002990 RID: 10640
		public Vector3 vctPos = Vector3.zero;

		// Token: 0x04002991 RID: 10641
		public Vector3 vctRot = Vector3.zero;

		// Token: 0x04002992 RID: 10642
		public Vector3 vctScl = Vector3.one;
	}
}
